package io.github.biezhi.elves.mapper;

import java.math.BigDecimal;
import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import io.github.biezhi.elves.credit.model.CompNameList;
import io.github.biezhi.elves.credit.model.CreditReport;
import io.github.biezhi.elves.model.CompAnnualReports;
import io.github.biezhi.elves.qcc.model.CompAnalysis;
import io.github.biezhi.elves.qcc.model.CompBasic;
import io.github.biezhi.elves.qcc.model.CompBasicInfo;
import io.github.biezhi.elves.qcc.model.CompBidUrlDate;
import io.github.biezhi.elves.qcc.model.CompBidUrlResolve;
import io.github.biezhi.elves.qcc.model.CompBidding;
import io.github.biezhi.elves.qcc.model.CompChangeRecord;
import io.github.biezhi.elves.qcc.model.CompQccCrawl;
import io.github.biezhi.elves.qcc.model.CompQuota;
import io.github.biezhi.elves.qcc.model.OutboundInvestment;

public interface CreditReportMapper {

	/**
	 * 查询未爬取的工商企业，即IS_SPIDER=0
	 * @return
	 */
	@Select("select comp_id as compId,comp_name as compName,is_spider as isSpider"
			+ " from t_comp_name_list where is_spider = 0 limit #{num}")
	public List<CompNameList> queryCompNameList(Integer num);
	
	/**
	 * 根据compId更新爬取状态,0表示未爬取，1表示已爬取，2表示爬取异常
	 * @param compId
	 */
	@Update("update t_comp_name_list set is_spider=#{state} where comp_id=#{compId}")
	void updateCompNameListState(@Param("compId") String compId,@Param("state") Integer state);

	/**
	 * 将爬取出来的数据存放到数据库表中
	 */
	@Insert("INSERT INTO t_credit_report (comp_id,comp_name, credit_report_url, request_type,param_name,param_value) "
			+" VALUES (#{compId},#{compName}, #{creditReportUrl},#{requestType},#{paramName},#{paramValue})")
	public void insertCreditReport(CreditReport creditReport);
	
}
